﻿namespace ctolua.Models.Areas
{
    /// <summary>
    /// 圆形区域
    /// </summary>
    public class MCirArea : MArea
    {
        private CirArea _cirArea;
        /// <summary>
        /// 圆形区域实体
        /// </summary>
        public CirArea cirArea
        {
            get { return this._cirArea; }
            set
            {
                this._cirArea = value;
                this.area = value;
            }
        }
        /// <summary>
        /// 圆形区域大小(半径)
        /// </summary>
        public double radius
        {
            get => game_api.get_circle_area_radius(this.cirArea).@float();
            set
            {
                game_api.set_cir_area_radius(this.cirArea, py.Fix32(value));
            }
        }
        /// <summary>
        /// 最小x
        /// </summary>
        public double min_x => game_api.get_circle_area_min_x(this.cirArea).@float();
        /// <summary>
        /// 最小y
        /// </summary>
        public double min_y => game_api.get_circle_area_min_y(this.cirArea).@float();
        /// <summary>
        /// 最大x
        /// </summary>
        public double max_x => game_api.get_circle_area_max_x(this.cirArea).@float();
        /// <summary>
        /// 最大y
        /// </summary>
        public double max_y => game_api.get_circle_area_max_y(this.cirArea).@float();


        /// <summary>
        /// 圆形区域内单位数量
        /// </summary>
        /// <returns>单位数量</returns>
        public int? get_unit_num_in_cir_area => game_api.get_unit_num_in_cir_area(this.cirArea);
        /// <summary>
        /// 圆形区域内所有未销毁单位
        /// </summary>
        /// <returns>单位组</returns>
        public UnitGroup get_unit_group_in_cir_area => game_api.get_unit_group_in_cir_area(this.cirArea);
        /// <summary>
        /// 圆形区域内所有物品
        /// </summary>
        /// <returns>物品组</returns>
        public ItemGroup get_item_group_in_cir_area => game_api.get_item_group_in_cir_area(this.cirArea);
        /// <summary>
        /// 圆形区域是否存在
        /// </summary>
        /// <returns>是否存在</returns>
        public bool? is_null => game_api.circle_area_is_exist(this.cirArea);

        /// <summary>
        /// 返回圆形区域内随机点
        /// </summary>
        /// <returns>随机点</returns>
        public MPoint get_random_point_in_circular_area => new MPoint(game_api.get_random_point_in_circular_area(this.cirArea));
        /// <summary>
        /// 返回圆形区域中心点
        /// </summary>
        /// <returns>中心点</returns>
        public MPoint point => new MPoint(game_api.get_circle_center_point(this.cirArea));
        public MCirArea()
        {

        }
        public MCirArea(CirArea cirArea)
        {
            this.cirArea = cirArea;
        }
        /// <summary>
        /// 通过区域ID返回圆形区域
        /// </summary>
        /// <param name="res_id ">  区域ID   </param>
        public MCirArea(int cirAreaID)
        {
            this.cirArea = game_api.get_circle_area_by_res_id(cirAreaID);
        }
        /// <summary>
        /// 创建圆形区域
        /// </summary>
        /// <param name="point ">  中心点   </param>
        /// <param name="radius ">  半径   </param>
        public MCirArea(Point point, double radius)
        {
            this.cirArea = game_api.create_new_cir_area(point, py.Fix32(radius));
        }
        /// <summary>
        /// 点是否在圆形区域内
        /// </summary>
        /// <param name="point ">  点   </param>
        /// <returns>点是否在圆形区域内</returns>
        public bool? judge_point_in_cir_area(Point point) => game_api.judge_point_in_cir_area(point, this.cirArea);
        /// <summary>
        /// 圆形区域是否拥有某tags
        /// </summary>
        /// <param name="tag ">  tag   </param>
        /// <returns>布尔值</returns>
        public bool? if_cir_area_has_tag(string tag) => game_api.if_cir_area_has_tag(this.cirArea, tag);
        /// <summary>
        /// 设置圆形区域内视野情况
        /// </summary>
        /// <param name="player ">  玩家   </param>
        /// <param name="is_vision ">  布尔变量   </param>
        /// <param name="is_vision_true ">  布尔变量   </param>
        /// <returns>圆形区域</returns>
        public void set_circle_vision_visibility(Role player, bool? is_vision, bool? is_vision_true) => game_api.set_circle_vision_visibility(this.cirArea, player, is_vision, is_vision_true);


        /// <summary>
        /// 根据tag获取对应的圆形区域
        /// </summary>
        /// <param name="tag ">  tag   </param>
        /// <returns>列表</returns>
        public static dynamic get_cir_areas_by_tag(string tag) => game_api.get_cir_areas_by_tag(tag);
        /// <summary>
        /// 最近创建的圆型区域
        /// </summary>
        /// <returns>圆型区域</returns>
        public static MCirArea get_cir_area_last_created() => new MCirArea(game_api.get_cir_area_last_created());

    }
}
